home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / INFO / QHELP135.ZIP / QHELP.8 next >
Text File  |  1987-03-26  |  11KB  |  249 lines

  1. ; HELP.COM by Bob Montgomery, 2/23/87
  2. ; This program is a generic help screen template for use with the A86
  3. ; assembler. The desired help message is written as db's at Hlpst in
  4. ; place of the test message that is there now. The only restrictions 
  5. ; on the help message are:
  6. ;    1. The message must not exceed 80 characters wide.
  7. ;    2. The message must not exceed 25 lines long.
  8. ;    3. Each help line must be the same length.
  9. ; The program will auto center the message on the display screen. The hot 
  10. ; key combo to bring up the help screen is defined as Hotkey below (set 
  11. ; for Cntl-Leftshift right now) and can be changed to another combination
  12. ; by changing the equate for Hotkey.
  13.  
  14.      jmp  Init           ;Initialize program
  15.  
  16. Esc  equ  1Bh
  17. Vidmem equ 0B800         ;Location of screen 0
  18. Monomem equ 0B000        ;Location of mono screen
  19. BWattr equ 70h           ;Grey background, black foreground
  20.  
  21. ; Bits in shift status
  22. Rtsh   equ 1
  23. Lftsh  equ 2
  24. Cntl   equ 4
  25. Alt    equ 8
  26. Scrl   equ 10h
  27. Numl   equ 20h
  28. Capl   equ 40h
  29.  
  30. Mode   db  ?             ;Current video mode
  31. Vpage  db  ?             ;Current video page
  32. Vidseg dw  ?             ;Current page segment
  33. Hlpflg db  0             ;1 => Help on
  34. Attr   db  ?             ;Attribute to use
  35. Cursor dw  ?             ;Current cursor type
  36.  
  37. ; =================================================================
  38. ; This is the VEdit Plus help message to be displayed in blue on white
  39. ; when Cntl-Left Shift pressed. 74 char X 25 lines screen size.
  40.  
  41. Colattr equ 71h          ;White background, blue foreground
  42. Hotkey equ Cntl+Lftsh    ;Cntl-Left Shift key combo brings up screen
  43.  
  44. Hlpst: db '╔══════════════════════════════════════════════════════════════════════════╗'  ;Border chars
  45. Linchr equ $-Hlpst       ;Chars on each help line
  46.      db   '║ QEdit 135 Help by Bob Montgomery  ^=Cntrl a=Alt s=Shitft   Esc to Exit   ║'
  47.      db   '║ Cursor Movement  Block/Find/Print      File              Miscellaneous   ║'
  48.      db   '╟─────────────────┬───────────────┬────────────────────┬───────────────────╢'
  49.      db   '║^PgUp Top of File│aL  Mark Block │^KE Edit New File   │F2 Add Line at Curs║'
  50.      DB   '║^PgDn End of File│aC  Copy Block │^KQ Quit & Exit     │F5 Make Top of Scrn║'
  51.      db   '║^Home Top of Scrn│aG  Del  Block │^KX Save File & Exit│F6    Del to EOL   ║'
  52.      db   '║^End  Bot of Scrn│aM  Move Block │^KR Load File @ Curs│^Y    Del This Line║'
  53.      db   '║ Home St. of Line│aU  Unmrk Block│^KS Save Curr File  │^Bksp Del Left Word║'
  54.      db   '║ End  End of Line│^PB Print Block│^KP Edit Prev File  │^T    Del Rght Word║'
  55.      db   '║^<--- Word Left  │^KW Write Block│^KN Edit Next File  │F4   Dup Line Above║'
  56.      DB   '║^---> Word Right │sF7 Sh Blk Left│^KD Quit with Prompt│^-   Dup Char Above║'
  57.      DB   '║^Z    Scroll Down│sF8 Sh Blk Rght│^KF Change Filename │^N   Split Line    ║'
  58.      DB   '║^W    Scroll Up  │^QF Find  Text │^KZ Del File on Disk│^OS  Split Screen  ║'
  59.      DB   '║aF5   Scroll Left│^QA Replc Text │^BL Load Scratch Buf│^OP  Prev Window   ║'
  60.      DB   '║aF6   Scroll Rght│^L Rep Last F/R│^BS Save Scratch Buf│^ON  Next Window   ║'
  61.      DB   '║sTab  Tab Left   │^PA Print All  │^BA Apnd Scratch Buf│^O1  Make 1 Window ║'
  62.      DB   '║ Tab  Tab Right  │^PM Set Prt Mar│aX   Quit all Files │^U Window Sep Up   ║'
  63.      DB   '║aA  Align to Prev│^PE Form Feed  │aF10 Save all & Quit│^\ Window Sep Down ║'
  64.      db   '╟─────────────────┴───────────────┴────────────────────┴───────────────────╢'
  65.      DB   '║sF1 Box Mode Togl│^KT Set Tab Wid│^OR Set Right Margin│^QL Undo Line Chngs║'
  66.      DB   '║sF2 Box Line Togl│^QT Tab Exp Tog│^OW Wordwrap Toggle │^J  Jump to Line   ║'
  67.      DB   '║ F9 Shell to DOS │^QO Tabs Out   │^QI Auto Indent Togl│^PP Set Page Size  ║'
  68.      db   '╚═════════════════╧═══════════════╧════════════════════╧═══════════════════╝'
  69. ; ====================================================================
  70.  
  71. Msglen equ $-Hlpst       ;# chars in help buffer
  72. Lines equ Msglen/Linchr  ;# lines of help
  73. Buflen equ 2*Msglen      ;Screen data buffer length
  74. Stlin equ (25-Lines)/2   ;Start line
  75. Stchr equ (80-Linchr)/2  ;Start byte on line
  76. Stscr equ 160*Stlin + 2*Stchr ;Start of mem to put help
  77.  
  78. Scrbuf: db Buflen dup (?) ;Buffer for screen data
  79.  
  80. ; New Int 9 routine - check for Cntrl-LShift; ignore others.
  81. ; Since Int 9 is called every time a key is pressed or released, and
  82. ; reads the keyboard thru some mysterious means in BIOS, we must call
  83. ; the old Int 9 as a subroutine each time an Int 9 is generated. But,
  84. ; an interrupt routine has a IRET instead of a RET as the return
  85. ; instruction, which pops the return address like a RET does, and then
  86. ; pops the flags. So to call Int 9 like a subroutine, we have to push
  87. ; the flags first; then when the the IRET is executed, control returns
  88. ; to our program with the stack pointer at the right place.
  89.  
  90. Start: push ax,bx,cx,dx,ds,es,di,si ;Save all for calling program
  91.      pushf               ;Put flags on stack since Int pops flags
  92. Oldint: call 0000:0000   ;Call old Int 9 to get key-will pop flags
  93.      mov  ah,2           ;Get shift status
  94.      Int  16h            ;in al
  95.      and  al,Hotkey      ;Only keep Hot keys
  96.      cmp  al,Hotkey      ;Were both pressed?
  97.      jne  Exit           ;No
  98.      mov  ds,cs          ;Yes, set ds=cs
  99.      cmp  Hlpflg,1       ;Is help already up?
  100.      jne  Go             ;No, put it up
  101. ; If help is already up, ignore the Hotkey.
  102. Exit: pop si,di,es,ds,dx,cx,bx,ax ;Restore all for calling program
  103.      iret                ;Pop return address and flags
  104.  
  105. ; Come here if should put up help.
  106. Go:  mov  al,Colattr     ;Assume color
  107.      mov  Attr,al
  108.      mov  ah,15          ;Get video mode in al
  109.      int  10h            ;and page in bh
  110.      mov  Mode,al        ;Save Mode
  111.      mov  Vpage,bh       ;and page
  112.      cmp  al,2           ;Mode=2?
  113.      je   Color          ;Yes
  114.      cmp  al,3           ;Mode=3?
  115.      je   Color          ;Yes
  116.      cmp  al,7           ;Mode=7? (mono)
  117.      jne  Exit           ;No, must be graphics so exit
  118.      mov  al,BWattr      ;Set B&W attribute
  119.      mov  Attr,al
  120.      mov  bx,Monomem     ;and start of mono video memory
  121.      jmp  short A0
  122. Color: mov  bl,0         ;Bx=256*display page
  123.      add  bx,Vidmem      ;Get display mem segment
  124. A0:  mov  ds,bx          ;in ds
  125.  
  126. ; Put up help screen.
  127. ; First save current screen to buffer.
  128.      call Hidecur        ;Hide cursor
  129.      call Vidoff         ;Disable video (avoids snow on CGA)
  130.      mov  dl,Lines       ;Get # lines of help
  131.      mov  es,cs          ;es=cs
  132.      mov  si,Stscr       ;ds:si points to help screen area in disp mem
  133.      mov  di,Scrbuf      ;es:di points to buffer for screen data
  134.      push si,es,ds       ;Save them
  135.      mov  ch,0           ;ch=0
  136.      mov  cl,Linchr      ;cx=chars/help line
  137. A1:  push si,cx          ;Save position in scrn mem & chars/line
  138.      cld                 ;Set to inc si & di
  139.      rep  movsw          ;Move screen to buffer
  140.      pop  cx,si          ;Get start of line & chars/line
  141.      add  si,160         ;Next line, same column
  142.      dec  dl             ;Done all lines?
  143.      jne  A1             ;No
  144.  
  145. ; Now put up help.
  146.      pop  es,ds,di       ;Now ds=cs, es:di=help scrn area in screen mem
  147.      push di,ds,es       ;Put back in orig order
  148.      mov  si,Hlpst       ;Point si to help data
  149.      mov  dl,Lines       ;Get chars/help line
  150.      mov  ah,Attr        ;Get char attribute (color)
  151. B1:  push di,cx          ;Save disp mem pos & chars/help line
  152. B2:  lodsb               ;Get a help char in al
  153.      stosw               ;Save char & attribute in screen mem
  154.      loop B2             ;Do whole line
  155.      pop  cx,di          ;Get start of disp line & chars/line
  156.      add  di,160         ;Next line, same column
  157.      dec  dl             ;Done all lines?
  158.      jne  B1             ;No
  159.      mov  Hlpflg,1       ;Yes, indicate help up
  160.      call Vidon          ;and enable video
  161.  
  162. ; Now, wait for the escape key; come here after each keypress (Int 9).
  163. Wait1: mov ah,0          ;Wait for a key
  164.      int  16h
  165.      cmp  al,Esc         ;Was it Escape?
  166.      jne  Wait1          ;No
  167.  
  168. ; If Esc was pressed, put the old screen back
  169.      pop  es,ds,di       ;ds=cs; es:di=start of help area in disp mem
  170.      mov  si,Scrbuf      ;Point to old screen data buffer
  171.      call Vidoff         ;Disable video (avoid snow on CGA)
  172.      mov  dl,Lines       ;Chars/help line
  173. C1:  push di,cx          ;Save scrn mem pointer & chars/line
  174.      rep  movsw          ;Move a line to scrn mem
  175.      pop  cx,di          ;Get start of line & chars/line
  176.      add  di,160         ;Next line, same column
  177.      dec  dl             ;Done all lines?
  178.      jne  C1             ;No
  179.      mov  Hlpflg,0       ;Yes, clear flag
  180.      call Vidon          ;Enable video
  181.      call Showcur        ;Turn cursor back on
  182.      jmp  Exit           ;and return
  183.  
  184. ; Sub to turn cursor off; come with ds=video.
  185. Hidecur: push cx,ds
  186.      mov  ds,cs          ;ds=cs
  187.      mov  ah,3           ;Get current cursor data
  188.      mov  bh,Vpage       ;for current page
  189.      int  10h
  190.      mov  Cursor,cx      ;Save cursor type
  191.      mov  ch,20h         ;Set cursor off
  192.      mov  ah,1
  193.      int  10h
  194.      pop  ds,cx
  195.      ret
  196.  
  197. ; Sub to turn cursor on; come with ds=cs.
  198. Showcur: mov  cx,Cursor  ;Set original cursor Type
  199.      mov  bh,Vpage
  200.      mov  ah,1
  201.      int  10h
  202.      ret
  203.  
  204. ; Turn video off
  205. Vidoff: cs cmp  Mode,7   ;Mono?
  206.      je   D0             ;Yes, skip wait for vert retrace
  207.      push ds,dx,ax
  208.      call Getmode        ;Get current video mode byte
  209.      and  al,0F7         ;Clear video enable bit
  210.      out  dx,al          ;Send to mode control port
  211.      pop  ax,dx,ds
  212. D0:  ret
  213.  
  214. ; Turn video on
  215. Vidon: cs cmp  Mode,7    ;Mono?
  216.      je   E0             ;Yes, skip wait for vert retrace
  217.      push ds,dx,ax
  218.      call Getmode        ;Get current video mode byte
  219.      or   al,8           ;Set video enable bit
  220.      out  dx,al          ;Send to mode control port
  221.      pop  ax,dx,ds
  222. E0:  ret
  223.  
  224. ; Sub to wait for vertical retrace to avoid snow on CGA screen.
  225. Vert: mov dx,3DAh        ;CRT status port
  226. F1:  in   al,dx          ;Read status
  227.      test al,8           ;Vert retrace?
  228.      je   F1             ;No
  229.      mov  dx,3D8h        ;Point to video mode port
  230.      ret                 ;Yes, return
  231.  
  232. Getmode: call Vert       ;Wait for vert retrace
  233.      mov  ax,40h         ;Get video mode
  234.      mov  ds,ax          ;at 465h
  235.      mov  al,b[65h]
  236.      ret                 ;and return
  237.  
  238. ; Come here to install the program as the new Int 9 routine.
  239. Init: mov ax,3509h       ;Get current Int 9 vector
  240.      int  21h            ;in es:bx
  241.      mov  ds,cs          ;this code
  242.      mov  w[Oldint+1],bx ;Save it
  243.      mov  w[Oldint+3],es
  244.      mov  ax,2509h       ;Set new Int 9 routine
  245.      mov  dx,Start
  246.      int  21h
  247.      mov  dx,Init        ;Terminate and
  248.      int  27h            ;stay resident
  249.